using NUnit.Framework;

namespace Microsoft.WowAddonStudio.Lua.Tests.Parser
{
    [TestFixture]
    public class ParserTestBase<TParser> where TParser : Microsoft.WowAddonStudio.Lua.Parser.Parser, new()
    {
        protected TParser parser;

        [SetUp]
        public virtual void SetUp()
        {
            // Create the parser
            parser = new TParser
                     {
                         Tracing = true,
                     };
        }

        protected void AssertParse()
        {
            bool success = parser.Parse();

            // Assert that parse was successful and a Chunk with an empty Block has been parsed
            Assert.IsTrue(success, "Parse was not successful.");

            // Assert chunk
            Assert.IsNotNull(parser.Chunk, "Parse was successful but not chunk was returned.");
        }
    }
}